package com.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebListener
public class MyListener implements ServletContextListener, HttpSessionListener, ServletRequestListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("MyListener 监听到 ServletContext 初始化");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("MyListener 监听到 ServletContext 被摧毁");
    }

    @Override
    public void requestDestroyed(ServletRequestEvent sre) {
        System.out.println("MyListener 监听到 ServletRequest 被摧毁");
    }

    @Override
    public void requestInitialized(ServletRequestEvent sre) {
        System.out.println("MyListener 监听到 ServletRequest 初始化");
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("MyListener 监听到 HttpSession 初始化");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("MyListener 监听到 HttpSession 被摧毁");
    }
}
